package me.zk.practice1.s;

import java.util.*;

/**
 * @author zhangkai
 * @date 2023/7/30 11:42
 */
public class LS49 {

    public List<List<String>> groupAnagrams(String[] strs) {

        Map<String,List<String>> map = new HashMap<>();

        for (String str : strs) {
            char[] chars = str.toCharArray();
            Arrays.sort(chars);
            String s2 = new String(chars);
            List<String> list = map.getOrDefault(s2,new ArrayList<String>());

            list.add(str);
            map.put(s2,list);

        }
        return new ArrayList<>(map.values());
    }
}
